package com.example.AIstudy.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.example.AIstudy.domain.StuAndProSet;
import com.example.AIstudy.domain.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface StuAndProSetDao extends BaseMapper<StuAndProSet> {

    //新增一个用户做套题的记录，并且实现id回填
    @Insert("INSERT INTO stuandproset(stuID,proSetID,startTime,endTime,score,isSubmitted) " +
            "VALUES (#{stuID},#{proSetID},#{startTime},#{endTime},#{score},#{isSubmitted})")
    @SelectKey(statement = "select last_insert_id()", keyProperty = "id",
            keyColumn = "id", resultType = Integer.class, before = false)
    void insertStuAndSet(StuAndProSet stuAndProSet);

    //分页获取套题记录
    @Select("SELECT * FROM stuandproset ${ew.customSqlSegment}")
    public IPage<StuAndProSet> findStuAndProset(IPage<StuAndProSet> page,
                                          @Param(Constants.WRAPPER) QueryWrapper<StuAndProSet> wrapper);
}
